class CreatePrivileges < ActiveRecord::Migration
  def self.up
    create_table :privileges do |t|
      t.column :user_id, :integer, :null => false
      t.column :blog_id, :integer, :null => false
      
      t.column :read, :boolean, :null => false, :default => true
      t.column :write, :boolean, :null => false, :default => false
      t.column :admin, :boolean, :null => false, :default => false
    end
    
    add_index :privileges, [:user_id, :blog_id], :unique => true
  end

  def self.down
    drop_table :privileges
  end
end
